home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
14642
/
14642.xpi
/
chrome
/
modules
/
trackers
/
video.js
< prev
next >
Wrap
Text File
|
2009-10-19
|
3KB
|
69 lines
/* Copyright 2009, Boomtango.com. All Rights Reserved. */
/* video.js
* Responsible for tracking video files
*/
var EXPORTED_SYMBOLS = ["video"];
var video = {
name: "Video",
name_plural: "Videos",
color: "#1a9dbd",
isInternal: true,
preview: function(doc, node, data){
if(data.preview){
var iframe = doc.createElement(
"iframe"
);
var txt = '<object width="320" height="265"><param name="movie" value="http://www.youtube.com/v/' + data.preview + '&hl=en&fs=1&color1=0x006699&color2=0x54abd6"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/' + data.preview + '&hl=en&fs=1&color1=0x006699&color2=0x54abd6" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="320" height="265"></embed></object>';
iframe.setAttribute("src",
"data:text/html," + encodeURI(txt));
iframe.setAttribute("width", "352");
iframe.setAttribute("height", "288");
node.appendChild(iframe);
}
},
onLoadTracks: function(url, doc){
var result = [];
if(url.substr(0,this._url.length) == this._url){
result.push(
{
type: "video",
preview: this._buildSnippet(url)
}
);
} else if(doc){
var yturl = "http://www.youtube.com";
(function(list){
var ctr = list.length;
while(ctr--){
var src = list[ctr].src;
if(src && src.substr(0, yturl.length) == yturl){
result.push(
{
type: "video",
preview: this._buildSnippet(src, true)
}
);
}
}
}).apply(this, [ doc.getElementsByTagName('embed')]);
}
return result;
},
_buildSnippet: function(url, embed){
var result = /[?&]v=([^&]*)/.exec(url);
if(result && result.length > 1){
return id = result[1];
} else if(embed){
var result = /\/v\/([^&]*)/.exec(url);
if(result && result.length > 1){
return id = result[1];
}
}
return "";
},
_url: "http://www.youtube.com/watch?v"
};